home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / gzip < prev    next >
Encoding:
Text File  |  2010-11-16  |  1.3 KB  |  55 lines

  1. # bash completion for gzip
  2.  
  3. have gzip || have pigz &&
  4. _gzip()
  5. {
  6.     local cur prev xspec helpopts
  7.  
  8.     COMPREPLY=()
  9.     _get_comp_words_by_ref cur prev
  10.     helpopts=`_parse_help ${COMP_WORDS[0]}`
  11.  
  12.     case $prev in
  13.         -b|--blocksize|-p|--processes|-S|--suffix|-h|--help|-V|--version)
  14.             return 0
  15.             ;;
  16.     esac
  17.  
  18.     if [[ "$cur" == -* ]]; then
  19.         COMPREPLY=( $( compgen -W "$helpopts -1 -2 -3 -4 -5 -6 -7 -8 -9" \
  20.             -- "$cur" ) )
  21.         return 0
  22.     fi
  23.  
  24.     local IFS=$'\t\n'
  25.  
  26.     xspec="*.@(gz|t[ag]z)"
  27.     if [[ "$prev" == --* ]]; then
  28.         [[ "$prev" == --decompress || \
  29.             "$prev" == --list || \
  30.             "$prev" == --test ]] && xspec="!"$xspec
  31.         [[ "$prev" == --force ]] && xspec=
  32.     elif [[ "$prev" == -* ]]; then
  33.         [[ "$prev" == -*[dlt]* ]] && xspec="!"$xspec
  34.         [[ "$prev" == -*f* ]] && xspec=
  35.     elif [[ "$prev" == '>' || "$prev" == '>>' ]]; then
  36.         xspec=
  37.     elif [ "$prev" = '<' ]; then
  38.         xspec=
  39.     fi
  40.  
  41.     _expand || return 0
  42.  
  43.     COMPREPLY=( $( compgen -f -X "$xspec" -- "$cur" ) \
  44.         $( compgen -d -- "$cur" ) )
  45. } &&
  46. complete -F _gzip -o filenames gzip pigz
  47.  
  48. # Local variables:
  49. # mode: shell-script
  50. # sh-basic-offset: 4
  51. # sh-indent-comment: t
  52. # indent-tabs-mode: nil
  53. # End:
  54. # ex: ts=4 sw=4 et filetype=sh
  55.